<template>
	<el-table
		border
		size="mini"
		class="small-size-table"
		:data="dataList"
		style="width: 100%;margin-bottom: 20px;"
		header-align="center"
		:header-cell-style="getRowClass"
		:span-method="mergeSameColumns"
	>
		<el-table-column
			align="center"
			label="历史相同IP"
			min-width="100"
			show-overflow-tooltip
			prop="sameIp"
		>
			{{ dataCount.sameHistoryIp === 0 ? '不存在' : '存在' }}
		</el-table-column>

		<el-table-column
			align="center"
			label="历史相同设备"
			min-width="100"
			show-overflow-tooltip
		>
			{{ dataCount.sameHistoryDevice === 0 ? '不存在' : '存在' }}
		</el-table-column>

		<el-table-column
			align="center"
			label="会员账号"
			min-width="120"
			show-overflow-tooltip
		>
			<template slot-scope="scope">
				{{ scope.row.userName || '-' }}
			</template>
		</el-table-column>

		<el-table-column
			align="center"
			label="同桌率"
			min-width="80"
			show-overflow-tooltip
		>
			<template slot-scope="scope">
				{{ handleNumVal(scope.row.deskmateRate) + '%' }}
			</template>
		</el-table-column>

		<el-table-column
			align="center"
			label="手牌数"
			min-width="80"
			show-overflow-tooltip
		>
			<template slot-scope="scope">
				{{ handleNumVal(scope.row.handCount) }}
			</template>
		</el-table-column>

		<el-table-column
			align="center"
			label="同桌手牌数"
			min-width="100"
			show-overflow-tooltip
		>
			{{ handleNumVal(dataCount.deskmateHandCount) }}
		</el-table-column>

		<el-table-column
			align="center"
			label="单挑手牌数"
			min-width="100"
			show-overflow-tooltip
		>
			{{ handleNumVal(dataCount.challengeHandCount) }}
		</el-table-column>
		<el-table-column
			align="center"
			label="同桌时长(h)"
			min-width="100"
			show-overflow-tooltip
		>
			{{ handleNumVal(dataCount.deskmateTimeCount) }}
		</el-table-column>

		<el-table-column
			align="center"
			label="同桌盈利"
			min-width="135"
			show-overflow-tooltip
		>
			<template slot-scope="scope">
				<span :style="handleNumberColor(scope.row.deskmateProfit)">
					{{
						handleNumber(
							scope.row.currency,
							scope.row.deskmateProfit
						)
					}}
				</span>
			</template>
		</el-table-column>
		<el-table-column
			align="center"
			label="不同桌盈利"
			min-width="135"
			show-overflow-tooltip
		>
			<template slot-scope="scope">
				<span :style="handleNumberColor(scope.row.notDeskmateProfit)">
					{{
						handleNumber(
							scope.row.currency,
							scope.row.notDeskmateProfit
						)
					}}
				</span>
			</template>
		</el-table-column>
		<el-table-column
			align="center"
			label="总盈利"
			min-width="135"
			show-overflow-tooltip
		>
			<template slot-scope="scope">
				<span :style="handleNumberColor(scope.row.totalProfit)">
					{{
						handleNumber(scope.row.currency, scope.row.totalProfit)
					}}
				</span>
			</template>
		</el-table-column>
		<el-table-column
			align="center"
			label="总投注"
			min-width="135"
			show-overflow-tooltip
		>
			<template slot-scope="scope">
				<span>
					{{ handleNumber(scope.row.currency, scope.row.betAmount) }}
				</span>
			</template>
		</el-table-column>

		<el-table-column
			align="center"
			label="盈利率"
			min-width="90"
			show-overflow-tooltip
		>
			<template slot-scope="scope">
				<span :style="handleNumberColor(scope.row.earningsRate)">
					{{ handleNumVal(scope.row.earningsRate) + '%' }}
				</span>
			</template>
		</el-table-column>

		<el-table-column align="center" min-width="90" show-overflow-tooltip>
			<template slot="header">
				<div>入池率</div>
				<div class="header-top-line">VPIP</div>
			</template>
			<template slot-scope="scope">
				{{ handleNumVal(scope.row.bringPoolRate) + '%' }}
			</template>
		</el-table-column>

		<el-table-column align="center" min-width="100" show-overflow-tooltip>
			<template slot="header">
				<div>翻牌前加注率</div>
				<div class="header-top-line">PFR</div>
			</template>
			<template slot-scope="scope">
				{{ handleNumVal(scope.row.preFlopRaiseRate) + '%' }}
			</template>
		</el-table-column>

		<el-table-column
			v-if="isShowAction"
			align="center"
			label="操作"
			width="100"
			fixed="right"
		>
			<span
				class="text-link"
				@click="
					handleJump({
						path: '/dxn/riskManager/partnerCardQuery'
					})
				"
			>
				查看详情
			</span>
		</el-table-column>
	</el-table>
</template>

<script>
import list from '@/mixins/list'
export default {
	mixins: [list],
	props: {
		isShowAction: {
			type: Boolean,
			default: false
		},
		dataList: {
			type: Array,
			default: () => []
		},
		dataCount: {
			type: Object,
			default: () => {
				return {}
			}
		},
		params: {
			type: Object,
			default: () => {}
		}
	},
	data() {
		return {
			mergeColumnArr: [0, 1, 5, 6, 7, 15]
		}
	},
	methods: {
		handleNumVal(val) {
			if (typeof val === 'number') {
				return val
			}
			return '-'
		},
		handleJump(obj) {
			obj.query = {
				userName: this.dataList[0]?.userName,
				deskmateUserName: this.dataList[1]?.userName,
				startQueryTime: this.params.queryStartTime,
				endQueryTime: this.params.queryEndTime
			}
			this.$router.push(obj)
		},
		mergeSameColumns({ row, column, rowIndex, columnIndex }) {
			if (this.mergeColumnArr.indexOf(columnIndex) > -1) {
				if (rowIndex % 2 === 0) {
					return {
						rowspan: 2,
						colspan: 1
					}
				} else {
					return {
						rowspan: 0,
						colspan: 0
					}
				}
			}
		}
	}
}
</script>
<style lang="scss" scoped>
.header-top-line {
	margin-top: -8px;
}
</style>
